package cn.edu.ujn.park.service;

import cn.edu.ujn.park.dao.Coupon;
import cn.edu.ujn.park.dao.CouponMapper;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CouponServiceImpl implements ICouponService{
    @Autowired
    private CouponMapper couponMapper;

    @Override
    public int deleteByPrimaryKey(Integer couponId) {
        return 0;
    }

    @Override
    public int insert(Coupon row) {
        return 0;
    }

    @Override
    public int insertSelective(Coupon row) {
        return 0;
    }

    @Override
    public Coupon selectByPrimaryKey(Integer couponId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Coupon row) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Coupon row) {
        return 0;
    }

    @Override
    public Page<Coupon> selectAll(Coupon coupon) {
        Page<Coupon> page = new Page<>();
        List<Coupon> list = couponMapper.selectAll(coupon);
        Integer count = couponMapper.selectCount();
        page.setRows(list);
        page.setPage(coupon.getStart());
        page.setTotal(count);
        page.setSize(coupon.getRows());
        return page;
    }

    @Override
    public Page<Coupon> selectByUserId(Coupon coupon) {
        Page<Coupon> page = new Page<>();
        List<Coupon> list = couponMapper.selectByUserId(coupon);
        Integer count = couponMapper.selectCountByUserId(coupon.getUserId());
        page.setRows(list);
        page.setPage(coupon.getStart());
        page.setTotal(count);
        page.setSize(coupon.getRows());
        return page;
    }

    @Override
    public List<Coupon> selectUserCoupon(Integer userId) {
        return couponMapper.selectUserCoupon(userId);
    }

    @Override
    public Integer selectCount() {
        return 0;
    }

    @Override
    public Integer acquireCoupon(Coupon coupon) {
        return couponMapper.acquireCoupon(coupon);
    }

    @Override
    public boolean used(Integer couponId) {
        return couponMapper.used(couponId);
    }
}
